﻿using DAL;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using word.UserControls;
using word.winform;

namespace word
{
    public delegate void RefreshChartDelegate(List<int> x, List<int> y, string type);
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent(); 
        }

        private void 新建用户ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            AddUsers addUsers = new AddUsers();
            addUsers.ShowDialog();
        }

        private void 用户管理ToolStripMenuItem1_Click(object sender, System.EventArgs e)
        {
            MainContainer.Controls.Clear();
            Dictionary<string, string> table = new Dictionary<string, string>();
            table.Add("用户编号", "u_ID");
            table.Add("用户名称", "u_Name");
            table.Add("用户类型", "u_Type");
            table.Add("用户密码", "u_Password");
            ShowData managerGoodsType = new ShowData(table, "Users");
            managerGoodsType.Height = this.Height;
            managerGoodsType.Width = this.Width;
            MainContainer.Controls.Add(managerGoodsType);
        }

        /// <summary>
        /// 协调用户控件与主窗体的大小
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Main_Resize(object sender, System.EventArgs e)
        {
            Task task = new Task(change);
            task.Start();
        }

        public void change()
        {
            try
            {
                MainContainer.Controls[0].Height = this.Height-50;
                MainContainer.Controls[0].Width = this.Width;
            }
            catch { }
        }

        private void 新增商品类型ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            AddGoodsType addGoodsType = new AddGoodsType();
            addGoodsType.ShowDialog();
        }

        private void 类型管理ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            MainContainer.Controls.Clear();
            Dictionary<string,string> table = new Dictionary<string, string>();
            table.Add("商品类别编号", "t_ID");
            table.Add("商品类别名称", "t_Name");
            table.Add("商品描述", "t_Description");
            ShowData managerGoodsType = new ShowData(table, "Types");
            managerGoodsType.Height = this.Height;
            managerGoodsType.Width = this.Width;
            MainContainer.Controls.Add(managerGoodsType);
        }

        private void 新增商品ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            winform.AddGoods addGoods = new winform.AddGoods();
            addGoods.Show();
        }

        private void 商品管理ToolStripMenuItem1_Click(object sender, System.EventArgs e)
        {
            MainContainer.Controls.Clear();
            Dictionary<string, string> table = new Dictionary<string, string>();
            table.Add("商品编号", "g_ID");
            table.Add("商品名称", "g_Name");
            table.Add("商品类别编号", "t_ID");
            table.Add("商品价格", "g_Price");
            table.Add("商品折扣", "g_Discount");
            table.Add("商品库存数量", "g_Number");
            table.Add("商品生产日期", "g_ProduceDate");
            table.Add("商品实物图", "g_Image");
            table.Add("商品销售状态", "g_Status");
            table.Add("商品描述", "g_Description");

            ShowData managerGoodsType = new ShowData(table, "[dbo].[Goods]");
            managerGoodsType.Height = this.Height;
            managerGoodsType.Width = this.Width;
            MainContainer.Controls.Add(managerGoodsType);
        }

        

        private void Main_Load(object sender, System.EventArgs e)
        {
            MainContainer.Controls.Clear();
            ChartMessage chartMessage = new ChartMessage();
            chartMessage.Width = this.Width;
            chartMessage.Height = this.Height-50;
            MainContainer.Controls.Add(chartMessage);
        }

        private void 主页面ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            MainContainer.Controls.Clear();
            ChartMessage chartMessage = new ChartMessage();
            chartMessage.Width = this.Width;
            chartMessage.Height = this.Height - 50;
            MainContainer.Controls.Add(chartMessage);
        }

        private void 关于此软件ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            AboutThisSofrWare aboutThisSofrWare = new AboutThisSofrWare();
            aboutThisSofrWare.ShowDialog();
        }

        private void 帮助ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            winform.Help help = new winform.Help();
            help.ShowDialog();
        }

        private void mDI子窗体ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            others.MDIP form1 = new others.MDIP();
            form1.Show();
        }

        private void 简单计算器ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.calculate().Show();
        }

        private void 前景背景编辑ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.BgForm().Show();
        }

        private void 判断男女ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.AudgeGender().Show();
        }

        private void 判断季节ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.ChooseSeason().Show();
        }

        private void 倒计时10分钟ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.lockTime().Show();
        }

        private void 时间控件ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.TimeControl().Show();
        }

        private void 滚动字幕ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.MoveLetter().Show();
        }

        private void 制作电子表ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.Timetoend().Show();
        }

        private void 进度条ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.Progress().Show();
        }

        private void 时间合成ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.date().Show();
        }

        private void 记事本ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            new others.color().Show();
        }
    }
}
